package com.valuegen;

import com.valuegen.generater.Remark;
import com.valuegen.generater.RemarkGenerater;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class ValueGeneraterActivity extends Activity {
	/** Called when the activity is first created. */

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		
		RemarkGenerater.setContext(this);
		final TextView value = (TextView) findViewById(R.id.value);
		final TextView comment = (TextView) findViewById(R.id.comment);
		final EditText nameInput = (EditText) findViewById(R.id.input);
		final Button calculate = (Button) findViewById(R.id.calculate);
		calculate.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View view) {
				String name = nameInput.getText().toString();
				try {
					Remark remark = RemarkGenerater.getRemark(name);
					value.setText(remark.getValue());
					comment.setText(remark.getComment());
				} catch (Exception e) {
					e.printStackTrace();
					Toast.makeText(ValueGeneraterActivity.this, e.getMessage(),
							0).show();
				}

			}
		});
		
	}

	@Override
	protected void onPause() {
		super.onPause();
		
	}

	@Override
	protected void onResume() {

		super.onResume();
		
	}

}
